package com.speedcar.base.model;

import lombok.Data;

/**
 * 统一返回信息包装类
 *
 * @author zhangfuzeng
 */
@Data
public class ScResultJson {

    private static final String SUCCESS_CODE = "200";

    /**
     * 成功失败的状态值，true：成功；false：失败
     * 这里返回编码为：“200”，系统就认为接口成功；其他值，代表失败
     */
    private Boolean status;

    /**
     * 状态码 正确为200
     */
    private String code;

    /**
     * 返回提示信息
     */
    private String message;

    /**
     * 返回数据
     */
    private Object data;

    public ScResultJson() {
        this.status = true;
        this.code = SUCCESS_CODE;
        this.message = "";
    }

    public ScResultJson(Object data) {
        this.status = true;
        this.code = SUCCESS_CODE;
        this.message = "";
        this.data = data;
    }

    public ScResultJson(String code, String message) {
        this.status = SUCCESS_CODE.equals(code);
        this.code = code;
        this.message = message;
    }

    /**
     * 如果返回状态码非0000，且接口状态为成功，请使用这个
     *
     * @param status  接口请求状态
     * @param code    返回code值
     * @param message 返回消息
     * @param data  返回数据
     */
    public ScResultJson(Boolean status, String code, String message, Object data) {
        this.status = status;
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
